local ServerOHOH = _G.ServerOHOH;
local M = ServerOHOH.class.new(script, ServerOHOH.files.Server_PlayerComponent(),script.Parent.Name);
local Players = game:GetService("Players")

local HTTP = game:GetService("HttpService")
function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent)
	self.player = self.parent
	self:AddConnect()
 
end;

function M.AddConnect(self)
	self.player.CharacterEnterEvent:Connect(function()
		self:Rebirth()
	end)
end

function M.Rebirth(self)
	self.RebirthPos = M.GetRebirthPos()
	self.RebirthPos:SetAttribute("isUsing",true)
	self.player.character:SetCFrame(self.RebirthPos.WorldCFrame)
	self:AddProcess(function()
		self:Wait(2)
		self.RebirthPos:SetAttribute("isUsing",false)
	end)
end

function M.GetRebirthPos()
    for _,v in pairs(workspace.RebirthPositions.ctrl:GetChildren()) do
        if not v.value:GetAttribute("isUsing") then
            return v.value
        end
    end
end

function M.dtor(self)
    M.super.dtor(self)
end

return M